package ua.cn.store.domain;

import java.sql.Timestamp;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@Entity
@Table(name="Comments")
@NamedQueries({
	@NamedQuery(name="Comment.getByDate",query="select c from Comment c where c.timestamp like :c_timestamp"),
	@NamedQuery(name="Comment.getCommentByBook",query="select c from Comment c where c.book.id=?1"),
	@NamedQuery(name="DeleteByBook",query="delete from Comment c where c.book.id=?1")
})
public class Comment extends Domain {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Timestamp timestamp;
	private String text;
	
	public void setText(String text) {
		this.text = text;
	}

	private Book book;
		
		
	@Column(name="text_c")
	@Lob
	public String getText() {
		return text;
	}
	
	@ManyToOne
	@JoinColumn(name="b_id")
	public Book getBook() {
		return book;
	}

	public void setBook(Book book) {
		this.book = book;
	}

	//@Temporal(TemporalType.TIMESTAMP)
    @Column(name="date_c")
	public Timestamp getTimestamp() {
		return timestamp;
	}

	public void setTimestamp(Timestamp timestamp) {
		this.timestamp = timestamp;
	}
	
	
}
